# -*- coding: utf-8 -*-
"""
实现多元线性回归模型
Created on Wed Feb 14 17:02:56 2018

@author: Allen
"""
import numpy as np
from playML.LinearRegression import LinearRegression
from playML.model_selection import train_test_split
from sklearn import datasets

boston = datasets.load_boston()
X = boston["data"]
y = boston["target"]

X = X[y<50]
y = y[y<50]

X_train, X_test, y_train, y_test = train_test_split( X, y, seed = 666 )

reg = LinearRegression()
reg.fit_normal( X_train, y_train )
r_squared = reg.score( X_test, y_test ) #0.81298026026585091
